package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.equTestListPojo;
import com.example.pojo.equipmentManagementPojo;
import com.example.pojo.equipmentTechnologyPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:equipmentManagementMapp
 * Description:
 *是《工装管理》
 * @Author 赵永峰
 * @Create 2024/9/22 23:06
 * @Version 1.0
 */
@Mapper
public interface equipmentManagementMapp {
    //插入一行《工装台账》
    @DS("baodingRussia")
    @Insert("insert into equipmentLedger (" +
            "clampName, position, department, " +
            "modelId, company, number, " +
            "exNumber, category, state, " +
            "workBookId, controlPlan, startDate, " +
            "endData, startEngineId, endEngineId, " +
            "endType, useNumber, deleteSign, " +
            "establishTime, updateTime, editName," +
            "detMark)" +
            " VALUES" +
            " (#{clampName},#{position},#{department}," +
            "#{modelId},#{company},#{number}," +
            "#{exNumber},#{category},#{state}," +
            "#{workBookId},#{controlPlan},#{startDate}," +
            "#{endData},#{startEngineId},#{endEngineId}," +
            "#{endType},#{useNumber},#{deleteSign}," +
            "#{establishTime},#{updateTime},#{editName}," +
            "#{detMark})")
    void insertOne(equipmentManagementPojo equipmentManagementPojo);
    //筛选出是装配车间管理的工装，所在的不同的位置,现在是查装配车间的
    @DS("baodingRussia")
    @Select("select distinct position from equipmentLedger where deleteSign=1 and department='装配车间/Assembly workshop/сборочный цех'")
    List<equipmentManagementPojo> queryDifferentByType1();
    //筛选出是装配车间管理的工装，所在的不同的位置,现在是查机加车间的
    @DS("baodingRussia")
    @Select("select distinct position from equipmentLedger where deleteSign=1 and department='机加车间/Machining workshop/Машиностроительный цех'")
    List<equipmentManagementPojo> queryDifferentByType2();
    //筛选出是装配车间管理的工装，所在的不同的位置,现在是查其他部门的
    @DS("baodingRussia")
    @Select("select distinct position from equipmentLedger where deleteSign=1 and department <> '机加车间/Machining workshop/Машиностроительный цех' and department <> '装配车间/Assembly workshop/сборочный цех'")
    List<equipmentManagementPojo> queryDifferentByType3();
    //根据传来的车间名称、存放位置，查询数据
    @DS("baodingRussia")
    @Select("select * from equipmentLedger where deleteSign=1 and department=#{filedVal1} and position=#{filedVal2}")
    List<equipmentManagementPojo> SelectClampData(String filedVal1, String filedVal2);
    @DS("baodingRussia")
    @Select("select * from equipmentLedger where deleteSign=1 and department <> '机加车间/Machining workshop/Машиностроительный цех' and department <> '装配车间/Assembly workshop/сборочный цех' and position=#{filedVal2}")
    List<equipmentManagementPojo> SelectClampDataType3(String filedVal2);
    //根据id，修改一行信息
    @DS("baodingRussia")
    @Update("update equipmentLedger set " +
            "clampName=#{clampName}," +
            "position=#{position}," +
            "department=#{department}," +
            "modelId=#{modelId}," +
            "company=#{company}," +
            "number=#{number}," +
            "exNumber=#{exNumber}," +
            "category=#{category}," +
            "state=#{state}," +
            "workBookId=#{workBookId}," +
            "controlPlan=#{controlPlan}," +
            "startDate=#{startDate}," +
            "endData=#{endData}," +
            "startEngineId=#{startEngineId}," +
            "endEngineId=#{endEngineId}," +
            "endType=#{endType}," +
            "useNumber=#{useNumber}," +
            "deleteSign=#{deleteSign}," +
            "establishTime=#{establishTime}," +
            "updateTime=#{updateTime}," +
            "editName=#{editName} " +
            "where id=#{id}")
    void editOne(equipmentManagementPojo equipmentManagementPojo);
    //插入一行数据（工装技术条件）
    @DS("baodingRussia")
    @Insert("insert into equipmentTechnology " +
            "(position, equipmentName, equipmentType, " +
            "useType, clampName, drawingNo, " +
            "modelId, controlProject, classification, " +
            "evaluate, capacity, frequency, " +
            "controlMethod, department, workBookId, " +
            "LedgerSign, deleteSign, establishTime, " +
            "updateTime, editName, trendMarkers, " +
            "source, workshop) " +
            "values " +
            "(#{position},#{equipmentName},#{equipmentType}," +
            "#{useType},#{clampName},#{drawingNo}," +
            "#{modelId},#{controlProject},#{classification}," +
            "#{evaluate},#{capacity},#{frequency}," +
            "#{controlMethod},#{department},#{workBookId}," +
            "#{LedgerSign},#{deleteSign},#{establishTime}," +
            "#{updateTime},#{editName},#{trendMarkers}," +
            "#{source},#{workshop})")
    void technologyInsertOne(equipmentTechnologyPojo equipmentTechnologyPojo);
    //查询树形导航结构,查询的是存放部位不重复，并且按照要求排序的,接收的是两个字段的字段名称。形成一个树形导航的数组（工装技术条件）
    @DS("baodingRussia")
    @Select("select distinct position from equipmentTechnology where deleteSign=1 and workshop='装配车间/Assembly workshop/сборочный цех'")
    List<equipmentTechnologyPojo> queryTechnologyDifferentByType1();
    @DS("baodingRussia")
    @Select("select distinct position from equipmentTechnology where deleteSign=1 and workshop='机加车间/Machining workshop/Машиностроительный цех'")
    List<equipmentTechnologyPojo> queryTechnologyDifferentByType2();
    @DS("baodingRussia")
    @Select("select distinct position from equipmentTechnology where deleteSign=1 and workshop <> '机加车间/Machining workshop/Машиностроительный цех' and workshop <> '装配车间/Assembly workshop/сборочный цех'")
    List<equipmentTechnologyPojo> queryTechnologyDifferentByType3();
    //根据传来的车间名称，存放位置，查询数据（工装技术条件）
    @DS("baodingRussia")
    @Select("select * from equipmentTechnology where deleteSign=1 and workshop=#{filedVal1} and position=#{filedVal2}")
    List<equipmentTechnologyPojo> SelectTechnologyData(String filedVal1, String filedVal2);
    @DS("baodingRussia")
    @Select("select * from equipmentTechnology where deleteSign=1 and workshop <> '机加车间/Machining workshop/Машиностроительный цех' and workshop <> '装配车间/Assembly workshop/сборочный цех' and position=#{filedVal2}")
    List<equipmentTechnologyPojo> SelectTechnologyDataType3(String filedVal2);
    //根据Id修改数据（工装技术条件）
    @DS("baodingRussia")
    @Update("update equipmentTechnology set " +
            "position=#{position}," +
            "equipmentName=#{equipmentName}," +
            "equipmentType=#{equipmentType}," +
            "useType=#{useType}," +
            "clampName=#{clampName}," +
            "drawingNo=#{drawingNo}," +
            "modelId=#{modelId}," +
            "controlProject=#{controlProject}," +
            "classification=#{classification}," +
            "evaluate=#{evaluate}," +
            "capacity=#{capacity}," +
            "frequency=#{frequency}," +
            "controlMethod=#{controlMethod}," +
            "department=#{department}," +
            "workBookId=#{workBookId}," +
            "LedgerSign=#{LedgerSign}," +
            "deleteSign=#{deleteSign}," +
            "establishTime=#{establishTime}," +
            "updateTime=#{updateTime}," +
            "editName=#{editName}," +
            "trendMarkers=#{trendMarkers}," +
            "source=#{source}," +
            "workshop=#{workshop} " +
            "where id=#{id}")
    void editTechnologyOne(equipmentTechnologyPojo equipmentTechnologyPojo);
    //向工装检测数据中插入一行检测数据
    @DS("baodingRussia")
    @Insert("insert into equTestList (" +
            "clampName, position, department, " +
            "modelId, company, number, " +
            "equLedList, project, projectEnglish, " +
            "projectRussian, standard, `limit`, " +
            "lower, standardType, valueUse, " +
            "testPer, capacity, editMess, " +
            "deleteSign, establishTime, updateTime, " +
            "testDate, frequency) " +
            "VALUES " +
            "(#{clampName},#{position},#{department}," +
            "#{modelId},#{company},#{number}," +
            "#{equLedList},#{project},#{projectEnglish}," +
            "#{projectRussian},#{standard},#{limit}," +
            "#{lower},#{standardType},#{valueUse}," +
            "#{testPer},#{capacity},#{editMess}," +
            "#{deleteSign},#{establishTime},#{updateTime}," +
            "#{testDate},#{frequency})")
    void equTestInsertOne(equTestListPojo equTestListPojo);
    //    查询最后检测的一条数据
    @DS("baodingRussia")
    @Select("select * from equTestList where deleteSign=1 and number=#{number} ORDER BY id DESC LIMIT 1;")
    equTestListPojo equLastTimeTest(equTestListPojo equTestListPojo);
}
